<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>
bz_webservice_demo.pl</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" title="style" type="text/css" href=".././../../../style.css" media="all" >

</head>
  <body id="pod">
<p class="backlinktop"><b><a name="___top" href="../index.html" accesskey="1" title="All Documents">&lt;&lt;</a></b></p>
<h1>bz_webservice_demo.pl</h1>
<div class='indexgroup'>
<ul   class='indexList indexList1'>
  <li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
  <li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
  <li class='indexItem indexItem1'><a href='#OPTIONS'>OPTIONS</a>
  <li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
  <ul   class='indexList indexList2'>
    <li class='indexItem indexItem2'><a href='#Initialization'>Initialization</a>
    <li class='indexItem indexItem2'><a href='#Checking_Bugzilla%27s_version'>Checking Bugzilla&#39;s version</a>
    <li class='indexItem indexItem2'><a href='#Checking_Bugzilla%27s_timezone'>Checking Bugzilla&#39;s timezone</a>
    <li class='indexItem indexItem2'><a href='#Getting_Extension_Information'>Getting Extension Information</a>
    <li class='indexItem indexItem2'><a href='#Logging_In_and_Out'>Logging In and Out</a>
    <ul   class='indexList indexList3'>
      <li class='indexItem indexItem3'><a href='#Using_Bugzilla%27s_Environment_Authentication'>Using Bugzilla&#39;s Environment Authentication</a>
      <li class='indexItem indexItem3'><a href='#Using_Bugzilla%27s_CGI_Variable_Authentication'>Using Bugzilla&#39;s CGI Variable Authentication</a>
    </ul>
    <li class='indexItem indexItem2'><a href='#Retrieving_Bug_Information'>Retrieving Bug Information</a>
    <li class='indexItem indexItem2'><a href='#Retrieving_Product_Information'>Retrieving Product Information</a>
    <li class='indexItem indexItem2'><a href='#Creating_A_Bug'>Creating A Bug</a>
    <li class='indexItem indexItem2'><a href='#Getting_Legal_Field_Values'>Getting Legal Field Values</a>
    <li class='indexItem indexItem2'><a href='#Adding_a_comment_to_a_bug'>Adding a comment to a bug</a>
  </ul>
  <li class='indexItem indexItem1'><a href='#NOTES'>NOTES</a>
  <ul   class='indexList indexList2'>
    <li class='indexItem indexItem2'><a href='#Character_Set_Encoding'>Character Set Encoding</a>
    <li class='indexItem indexItem2'><a href='#Format_For_Create_File'>Format For Create File</a>
  </ul>
  <li class='indexItem indexItem1'><a href='#SEE_ALSO'>SEE ALSO</a>
</ul>
</div>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>

<p>bz_webservice_demo.pl - Show how to talk to Bugzilla via XMLRPC</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>

<p><code  class="code">bz_webservice_demo.pl [options]</code></p>

<p><code  class="code">bz_webservice_demo.pl --help</code> for detailed help</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="OPTIONS"
>OPTIONS</a></h1>

<dl>
<dt><a name="--help,_-h,_-?"
>--help,
-h,
-?</a></dt>

<dd>
<p>Print a short help message and exit.</p>

<dt><a name="--uri"
>--uri</a></dt>

<dd>
<p>URI to Bugzilla&#39;s <code  class="code">xmlrpc.cgi</code> script,
along the lines of <code  class="code">http://your.bugzilla.installation/path/to/bugzilla/xmlrpc.cgi</code>.</p>

<dt><a name="--login"
>--login</a></dt>

<dd>
<p>Bugzilla login name.
Specify this together with <b>--password</b> in order to log in.</p>

<p>Specify this without a value in order to log out.</p>

<dt><a name="--password"
>--password</a></dt>

<dd>
<p>Bugzilla password.
Specify this together with <b>--login</b> in order to log in.</p>

<dt><a name="--rememberlogin"
>--rememberlogin</a></dt>

<dd>
<p>Gives access to Bugzilla&#39;s &#34;Bugzilla_remember&#34; option.
Specify this option while logging in to do the same thing as ticking the <code  class="code">Bugzilla_remember</code> box on Bugilla&#39;s log in form.
Don&#39;t specify this option to do the same thing as unchecking the box.</p>

<p>See Bugzilla&#39;s rememberlogin parameter for details.</p>

<dt><a name="--bug_id"
>--bug_id</a></dt>

<dd>
<p>Pass a bug ID to have <code  class="code">bz_webservice_demo.pl</code> do some bug-related test calls.</p>

<dt><a name="--product_name"
>--product_name</a></dt>

<dd>
<p>Pass a product name to have <code  class="code">bz_webservice_demo.pl</code> do some product-related test calls.</p>

<dt><a name="--create"
>--create</a></dt>

<dd>
<p>Specify a file that contains settings for the creating of a new bug.</p>

<dt><a name="--field"
>--field</a></dt>

<dd>
<p>Pass a field name to get legal values for this field.
It must be either a global select field (such as bug_status,
resolution,
rep_platform,
op_sys,
priority,
bug_severity) or a custom select field.</p>

<dt><a name="--comment"
>--comment</a></dt>

<dd>
<p>A comment to add to a bug identified by <b>--bug_id</b>.
You must also pass a <b>--login</b> and <b>--password</b> to log in to Bugzilla.</p>

<dt><a name="--private"
>--private</a></dt>

<dd>
<p>An optional non-zero value to specify <b>--comment</b> as private.</p>

<dt><a name="--worktime"
>--worktime</a></dt>

<dd>
<p>An optional double precision number specifying the work time for <b>--comment</b>.</p>

<dt><a name="--extension_info"
>--extension_info</a></dt>

<dd>
<p>If specified on the command line,
the script returns the information about the extensions that are installed.</p>
</dd>
</dl>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Initialization"
>Initialization</a></h2>

<p>Using the XMLRPC::Lite class,
you set up a proxy,
as shown in this script.
Bugzilla&#39;s XMLRPC URI ends in <code  class="code">xmlrpc.cgi</code>,
so your URI looks along the lines of <code  class="code">http://your.bugzilla.installation/path/to/bugzilla/xmlrpc.cgi</code>.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Checking_Bugzilla&#39;s_version"
>Checking Bugzilla&#39;s version</a></h2>

<p>To make sure the Bugzilla you&#39;re connecting to supports the methods you wish to call,
you may want to compare the result of <code  class="code">Bugzilla.version</code> to the minimum required version your application needs.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Checking_Bugzilla&#39;s_timezone"
>Checking Bugzilla&#39;s timezone</a></h2>

<p>To make sure that you understand the dates and times that Bugzilla returns to you,
you may want to call <code  class="code">Bugzilla.timezone</code>.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Getting_Extension_Information"
>Getting Extension Information</a></h2>

<p>Returns all the information any extensions have decided to provide to the webservice.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Logging_In_and_Out"
>Logging In and Out</a></h2>

<h3><a class='u' href='#___top' title='click to go to top of document'
name="Using_Bugzilla&#39;s_Environment_Authentication"
>Using Bugzilla&#39;s Environment Authentication</a></h3>

<p>Use a <code  class="code">http://login:password@your.bugzilla.installation/path/to/bugzilla/xmlrpc.cgi</code> style URI.
You don&#39;t log out if you&#39;re using this kind of authentication.</p>

<h3><a class='u' href='#___top' title='click to go to top of document'
name="Using_Bugzilla&#39;s_CGI_Variable_Authentication"
>Using Bugzilla&#39;s CGI Variable Authentication</a></h3>

<p>Use the <code  class="code">User.login</code> and <code  class="code">User.logout</code> calls to log in and out,
as shown in this script.</p>

<p>The <code  class="code">Bugzilla_remember</code> parameter is optional.
If omitted,
Bugzilla&#39;s defaults apply (as specified by its <code  class="code">rememberlogin</code> parameter).</p>

<p>Bugzilla hands back cookies you&#39;ll need to pass along during your work calls.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Retrieving_Bug_Information"
>Retrieving Bug Information</a></h2>

<p>Call <code  class="code">Bug.get</code> with the ID of the bug you want to know more of.
The call will return a <code  class="code">Bugzilla::Bug</code> object.</p>

<p>Note: You can also use &#34;Bug.get_bugs&#34; for compatibility with Bugzilla 3.0 API.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Retrieving_Product_Information"
>Retrieving Product Information</a></h2>

<p>Call <code  class="code">Product.get_product</code> with the name of the product you want to know more of.
The call will return a <code  class="code">Bugzilla::Product</code> object.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Creating_A_Bug"
>Creating A Bug</a></h2>

<p>Call <code  class="code">Bug.create</code> with the settings read from the file indicated on the command line.
The file must contain a valid anonymous hash to use as argument for the call to <code  class="code">Bug.create</code>.
The call will return a hash with a bug id for the newly created bug.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Getting_Legal_Field_Values"
>Getting Legal Field Values</a></h2>

<p>Call <code  class="code">Bug.legal_values</code> with the name of the field (including custom select fields).
The call will return a reference to an array with the list of legal values for this field.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Adding_a_comment_to_a_bug"
>Adding a comment to a bug</a></h2>

<p>Call <code  class="code">Bug.add_comment</code> with the bug id,
the comment text,
and optionally the number of hours you worked on the bug,
and a boolean indicating if the comment is private or not.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="NOTES"
>NOTES</a></h1>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Character_Set_Encoding"
>Character Set Encoding</a></h2>

<p>Make sure that your application either uses the same character set encoding as Bugzilla does,
or that it converts correspondingly when using the web service API.
By default,
Bugzilla uses UTF-8 as its character set encoding.</p>

<h2><a class='u' href='#___top' title='click to go to top of document'
name="Format_For_Create_File"
>Format For Create File</a></h2>

<p>The create format file is a piece of Perl code,
that should look something like this:</p>

<pre  class="code">    {
        product     =&#62; &#34;TestProduct&#34;, 
        component   =&#62; &#34;TestComponent&#34;,
        summary     =&#62; &#34;TestBug - created from bz_webservice_demo.pl&#34;,
        version     =&#62; &#34;unspecified&#34;,
        description =&#62; &#34;This is a description of the bug... hohoho&#34;,
        op_sys      =&#62; &#34;All&#34;,
        platform    =&#62; &#34;All&#34;,   
        priority    =&#62; &#34;P4&#34;,
        severity    =&#62; &#34;normal&#34;
    };</pre>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="SEE_ALSO"
>SEE ALSO</a></h1>

<p>There are code comments in <code  class="code">bz_webservice_demo.pl</code> which might be of further help to you.</p>
<p class="backlinkbottom"><b><a name="___bottom" href="../index.html" title="All Documents">&lt;&lt;</a></b></p>

<!-- end doc -->

</body></html>
